
package com.monlyu.vo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;

import com.monlyu.annotation.Comment;
import com.monlyu.util.HashUtil;

/**
 * 角色所对应的权限
 * 
 * @author monlyu
 * @since 2010-1-7
 */
@Entity
@Table(name = "t_r2p")
@IdClass(value = Role2Permission.class)
@Comment(common = "角色权限对应表")
public class Role2Permission extends BaseVo implements Serializable {

    private static final long serialVersionUID = 5079396673448442501L;

    @Id
    @Column(name = "r2p_roleId")
    @Comment(common = "角色的ID")
    private Long roleId;

    @Id
    @Column(name = "r2p_perionId", length = BaseVo.LENGTH_50)
    @Comment(common = "权限ID")
    private String permissionId = "";

    public Long getRoleId(){
        return roleId;
    }

    public void setRoleId(Long roleId){
        this.roleId = roleId;
    }

    public String getPermissionId(){
        return permissionId;
    }

    public void setPermissionId(String permissionId){
        this.permissionId = permissionId;
    }

    @Override
    public boolean equals(Object obj){
        if (!(obj instanceof Role2Permission)) {
            return false;
        }
        return HashUtil.equals(roleId, ((Role2Permission) obj).roleId)
            && HashUtil.equals(permissionId, ((Role2Permission) obj).permissionId);
    }

    @Override
    public int hashCode(){
        return HashUtil.hash(roleId, permissionId);
    }
}
